wifi.setmode(wifi.STATIONAP)
wifi.sta.config({ssid="@PHICOMM_DC",pwd="123321000"})
wifi.ap.config({ssid="@PHICOMM_D",pwd="123321000"})
cfg =
{
    ip="192.168.1.1",
    netmask="255.255.255.0",
    gateway="192.168.1.1"
}
wifi.ap.setip(cfg)
dhcp_config ={}
dhcp_config.start = "192.168.1.100"
wifi.ap.dhcp.config(dhcp_config)
wifi.ap.dhcp.start()
wifi.sta.connect()
t = tmr.create()
t:register(1000,tmr.ALARM_AUTO,function()
     if wifi.sta.getip() == nil then
            print("connecting...")
     else 
            print("connected,Ip is "..wifi.sta.getip()) 
            t:stop()
            udpSocket = net.createUDPSocket()
            udpSocket:listen(5000)
            port, ip = udpSocket:getaddr()
            print(string.format("local UDP socket address / port: %s:%d", ip, port))   
            udpSocket:on("receive", function(s, data, port, ip)
    print(string.format("received '%s' from %s:%d", data, ip, port))
    s:send(port, ip, "echo: " .. data)
end)
    end
end)
t:start()
